from django.shortcuts import render
import os
# Create your views here.
def index(request):
    return render(request,'index.html')

def test(request):
    reqpost = request.POST
    reqfiles = request.FILES

    print(reqpost)
    print(reqfiles)

    print(reqpost['textarea'])

    if(reqfiles.get('musicfile')!=None):
        musicfile = reqfiles.get('musicfile')
        name = musicfile.name
        size = musicfile.size
        print(name,size)
        file_path = os.path.join('', 'upload', musicfile.name)
        # file_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+"\\upload"
        print(file_path)
        with open(file_path, 'wb') as f:
            for chunk in musicfile.chunks():
                f.write(chunk)
    else:
        print('musicfile为空')

    if(reqfiles.get('textfile')!=None):
        print('textfile',reqfiles['textfile'])
    else:
        print('textfile为空')

    return render(request,'index.html')